package top.igotcha.mapreduce.flowpartition.partition;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;
import top.igotcha.mapreduce.flowpartition.bean.FlowBean;

/**
 * @author Gotcha
 * @date 2021/1/12
 * @describe
 */
public class FlowPartition extends Partitioner<FlowBean, Text> {
    @Override
    public int getPartition(FlowBean flowBean, Text text, int i) {
        String phoneNum = text.toString();
        String phoneStart = phoneNum.substring(0,3);
        switch (phoneStart){
            case "135":
                return 0;
            case "136":
                return 1;
            case "137":
                return 2;
            default:
                return 3;
        }
    }
}
